<template>
  <div id="main" class="lineChart">折线图</div>
</template>

<script>
import * as echarts from 'echarts'

export default {
  mounted() {
    var chartDom = document.getElementById('main')
    var myChart = echarts.init(chartDom)
    var option

    option = {
      xAxis: {
        type: 'category',
        data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
      },
      legend: {
        data: ['销售额', '销售数量']
      },
      yAxis: {
        type: 'value'
      },
      series: [
        {
          name: '销售额',
          data: [820, 932, 901, 934, 1290, 1330, 1320],
          type: 'line',
          smooth: true
        },
        {
          name: '销售数量',
          data: [1620, 1992, 601, 934, 1890, 630, 2320],
          type: 'line',
          smooth: true
        }
      ]
    }

    option && myChart.setOption(option)
  }
}
</script>

<style scoped>
.lineChart {
  width: 100%;
  height: 400px;
  background-color: var(--main-bg-color);
}
</style>
